<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title></title>
		<script src="../js/mui.min.js"></script>
		<link href="../css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" type="text/css" href="../css/head.css" />

	</head>

	<body>
		<div class="mui-card">
			<!--页眉，放置标题-->
			<div class="mui-card-header mui-card-media" style="height:666px;background-image:url(../images/yuan1.jpg)">
				<a id="quxiao" href="#"><span class="mui-icon mui-icon-closeempty"></span></a>
				<button type="button" id="zhuce" class="mui-btn mui-pull-right">登录</button>
				<div class="zhuce">
					<center>
						注册
					</center>
					<form class="mui-input-group">
						<div class="mui-input-row">
							<label>用户名</label>
							<input type="text" class="mui-input-clear" id="name" placeholder="请输入用户名">
						</div>
						<div class="mui-input-row">
							<label>密码</label>
							<input type="password" class="mui-input-password" id="passw" placeholder="请输入密码">
						</div>
						<div class="mui-input-row">
							<label>确认密码</label>
							<input type="password" class="mui-input-password" id="password" placeholder="请再次输入密码">
						</div>
						<div class="mui-button-row">
							<button type="button" id="qrzc" class="mui-btn-danger">注册</button>
						</div>
					</form>
				</div>
				<center class="author">@copyright WZS</center>
			</div>

		</div>

	</body>
	<script type="text/javascript" charset="utf-8">
		mui.init({
			swipeBack: true //启用右滑关闭功能

		});
	window.onload = function(){
		document.getElementById("quxiao").addEventListener('tap', function() {
			mui.openWindow({
				url: '../index.html'
			})
		});

		document.getElementById("zhuce").addEventListener('tap', function() {
			mui.openWindow({
				url: './Denglu.html'
			});
		});

		//注册页面
		document.getElementById("qrzc").addEventListener('tap', function() {
			var username = document.getElementById("name").value;
			var passw = document.getElementById("passw").value;
			var password = document.getElementById("password").value;

			if(username.length == 0) {
				mui.toast("用户名不能为空");
			} else if(passw.length == 0) {
				mui.toast("密码不能为空");
			} else if(password.length == 0) {
				mui.toast("确认密码不能为空");
			} else {
				if(passw != password) {
					mui.toast("两次密码不一致");
				} else {
					mui.post('http://10.2.43.24/APP/QiJiaVIDEOS/PHP/zhuce.php', {
						username: username,
						password: password
					}, function(data) {
						//服务器返回响应，根据响应结果，分析是否登录成功；
						console.log(data.code);
						if(data == "9998") {
							mui.toast("用户名在4到10位，并且为字母数字");
						} else if(data == "9999") {
							mui.toast("密码在6到10位，并且为字母数字");
						} else {
							if(data.code == "10001") {
								mui.alert('success', '注册成功', function() {
									mui.openWindow({
										url: '../index.html',
										id: 'index.html',
										
									});
								});
								
								var preUrl = plus.webview.currentWebview().opener();
								mui.fire(preUrl,"updateUser",{
									name:data.data.NAME,
									
								})
								mui.currentWebview.close();
							} else if(data == "10002") {
								alert("用户名已被注册");
							} else {
								alert("注册失败");
							}
						}
					},'json');
				}
			}

		});
	}
	</script>

</html>